<?php
// Start the session
@session_start();

$id = session_id();
if ($id == "") {
	exit;
}

// If folder does not exist just exit
$tmpDataFolder = "../tmp_data/" . $id;
if (!file_exists($tmpDataFolder)) {
	exit();
}

// Execute detect landmarks
$output = exec(realpath(dirname(__FILE__) . "/../../detectLandmark/detectLandmarks"). " " . realpath(dirname(__FILE__) . "/../tmp_data/" . $id), $output);

/*$array = explode("\n", $output);
$facePoints = array();
foreach($array as $element) {
	preg_match_all("/\d+/", $element, $matches);
	$result = array();
	array_push($result, $matches[0][0]); array_push($result, $matches[0][1]); array_push($result, $matches[0][2]); array_push($result, $matches[0][3]);
	$facePoints[] = $result;
}
echo json_encode($facePoints);*/

// Load landmark xml
$landmarkXML = simplexml_load_file(realpath(dirname(__FILE__) . "/../tmp_data/" . $id . "/landmarks.xml"));
echo json_encode($landmarkXML);

?>